<?php
// vim:set expandtab tabstop=3 shiftwidth=3 softtabstop=3 foldclose=all foldmethod=marker:
/**
 * 项目：   5anet
 * 文件：   class/article/ShowArticle.class.php
 *
 * 显示文章的内容
 *
 * PHP Version 5
 *
 * @package:   class.article
 * @author:    Mike.G Chinese Name: 黄叶 <hylinux@gmail.com>
 * @license:   http://www.gnu.org/copyleft/lesser.html  LGPL License 2.1 
 * @copyright: www.5anet.com
 * @version:   $Id: ShowArticle.class.php,v 1.1 2006-09-24 14:38:33 ghw Exp $
 * @date:      $Date: 2006-09-24 14:38:33 $
 */

include_once CLASS_PATH.'main/BaseAction.class.php';

//包含我们需要的工具软件包
include_once CLASS_PATH.'article/CategoryUtil.class.php';
include_once CLASS_PATH.'article/ArticleUtil.class.php';



//include the language file
if ( file_exists(LANG_PATH.SYSTEM_LANG.'/ShowArticle.lang.php') ) {
   include_once LANG_PATH.SYSTEM_LANG.'/ShowArticle.lang.php';
}

//定义处理的类

class ShowArticle extends BaseAction {

   /**
    * 数据库的连接
    */
   private $db;

   /**
    * 构造函数
    * @param:  NULL
    * @return: NULL
    * @access: public
    */
   public function __construct() {
      $this->db = $this->getDB();
   }


   /**
    * 显示文章内容
    * @param:  NULL
    * @return: NULL
    * @access: public
    */
   public function run() {

      //取得文章的id
      $id = $this->getParameterFromGET('id');

      if ( !$id ) {
         $this->AlertAndBack('没有指定需要查看的文章的id');
         return;
      }

      //验证文章是否存在

      if ( !ArticleUtil::isExists($this->db, $id) ) {
         $this->AlertAndBack('你需要查看的文章不存在或者是管理员删除了。');
         return;
      }


      //取得模板系统的引用
      $smarty = $this->getSmarty();

      //显示头
      $categroy = CategoryUtil::getTopCategory($this->db);
      $smarty->assign('catagroy', $categroy);

      //取得文章所在的文章分类的信息
      $catagory_info = ArticleUtil::getCatagoryInfoById($this->db, $id);
      $smarty->assign('catagory_id', $catagory_info['id']);
      $smarty->assign('catagory_name', $catagory_info['name']);

      //取得文章的信息
      $article_info = ArticleUtil::getArticleInfor($this->db, $id);
      $smarty->assign('article_id', $article_info['id']);
      $smarty->assign('article_content', $article_info['content']);
      $smarty->assign('articletitle', $article_info['title']);
      $smarty->assign('clicks', $article_info['clicks']);
      $smarty->assign('fromaddress', $article_info['fromaddr']);
      $smarty->assign('submitDate', $article_info['submitDate']);
      $smarty->assign('submitUser', $article_info['submitUser']);


      //为SEO设置网站的信息
      $smarty->assign('clone_title', $article_info['title'].'/文章查看/5anet.com' );
      $smarty->assign('header_meta_content', $article_info['keyword'].'/'.
         $article_info['title'].' 5anet.com'); 

      //取得文章的评论
      $comment = ArticleUtil::getArticleComment($this->db, $id);

      $smarty->assign('comment', $comment);

      //更新文章被查看的次数
      ArticleUtil::UpdateClicks($this->db, $id);



      $smarty->display('showarticle.tmpl');



   }

}

?>
